package com.example.comcumer.Listener;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;



@Component
@Slf4j
public class RabbitmqListener {


    @RabbitListener(queues = "wjj-real-test1")  // 监听的队列名称
    public void receive1(String msg) {  //msg为接收到的消息
        log.info("接收到的消息为：" + msg);
    }


    //定义消息队列,交换机，当定，并监听
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name="wjj-fasterCreate-queue", durable = "true"),
            exchange = @Exchange(name="wjj-fasterCreate-exchange",type = "direct"),
            key = {"wjj-fasterCreate-test1","wjj-fasterCreate-test2"}
    ))
    public void receive2(String msg) {
        log.info("接收到的消息为：" + msg);
    }
}
